package com.choudou5.tools.builder;

import java.util.ArrayList;

/**
 * ArrayList 扩展
 */
public class ListBuilder<E> extends ArrayList<E> {

    public static ListBuilder cre(Object e){
        return new ListBuilder().ad(e);
    }

    public static ListBuilder cre(Object ... arr){
        return new ListBuilder().adds(arr);
    }

    public ListBuilder ad(E e) {
        this.add(e);
        return this;
    }

    public ListBuilder ad(boolean condition, E e) {
        if(condition)
            this.add(e);
        return this;
    }

    public ListBuilder adds(E ... arr) {
        if(arr != null){
            for (E e : arr) {
                this.add(e);
            }
        }
        return this;
    }

}
